import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/* Router Modules */
// import componentsRouter from './modules/components'
// import chartsRouter from './modules/charts'
// import tableRouter from './modules/table'
// import nestedRouter from './modules/nested'

export const constantRoutes = [
  // {
  //   path: '/redirect',
  //   component: Layout,
  //   hidden: true,
  //   children: [
  //     {
  //       path: '/redirect/:path*',
  //       component: () => import('@/views/redirect/index')
  //     }
  //   ]
  // },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/auth-redirect',
    component: () => import('@/views/login/auth-redirect'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/error-page/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/error-page/401'),
    hidden: true
  },
  {
    path:'/bigData',
    component: () => import('@/views/bigData/index'),
    name:'bigData',
    meta: { title: '数据大屏', icon: 'dashboard',affix: true}
  },
  {
    path: '/',
    component: Layout,
    redirect: '/homePage',
    children: [
      {
        path: 'homePage',
        component: () => import('@/views/homePage/index'),
        name: 'homePage',
        meta: { title: '首页', icon: 'dashboard', affix: true }
      }
    ]
  },


]

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [
  {
    id:'981fe9ffdcdd4406b75f7863337a51bb',
    path:'/parking',
    component:Layout,
    name:'parking',
    meta: {
      title: '停车场管理',
      icon: 'nested',
    },
    children: [
       {
        // id:"9a478740070a4ea7afc481fc0b624e4f",
        path: 'parkingManage',
        component: () => import('@/views/parking/parkingManage'),
        name: 'parkingManage',
        meta:{ title: '停车场管理', icon: 'guide'}
      },
      {
        // id:"a8d5e0b4fe2244ae8a9f499e6d306312",
        path: 'timeManage',
        component: () => import('@/views/parking/timeManage'),
        name: 'timeManage',
        meta:{ title: '合作时长管理', icon: 'guide'}
      },
    ]
  },
  {
    // id:'7400932409334f40bbef47e3009b2080',
    path: '/inOutPark',
    component: Layout,
    name:'inOutPark',
    children: [
      {
        path: 'inOutPark',
        component: () => import('@/views/inOutPark/index'),
        name: 'inOutPark',
        meta: { title: '出入场管理', icon: 'nested', }
      }
    ]
  },
  {
    // id:'7400932409334f40bbef47e3009b2080',
    path: '/marketing',
    component: Layout,
    name:'marketing',
    meta: {
      title: '营销管理',
      icon: 'nested',
    },
    children: [
      {
        path: 'coupon',
        component: () => import('@/views/marketing/coupon/index'),
        name: 'coupon',
        meta: { title: '优惠券', icon: 'nested', }
      }
    ]
  },
  {
    // id:"d33448c8f5e044d0830b562e59a169d4",
    path: '/member',
    component: Layout,
    name:'member',
    children: [
      {
        path: 'member',
        component: () => import('@/views/member/index'),
        name: 'member',
        meta: { title: '会员管理', icon: 'nested', }
      }
    ]
  },
  {
    // id:"86306d3f58ec4bf79237861217c88062",
    path: '/service',
    component: Layout,
    name:'service',
    children: [
      {
        path: 'service',
        component: () => import('@/views/service/index'),
        name: 'service',
        meta: { title: '服务项目管理', icon: 'nested', }
      }
    ]
  },
   {
    // id:"499c5f4297c24497a57e796026874285",
    path:'/finance',
    component:Layout,
    name:'finance',
    meta: {
      title: '财务管理',
      icon: 'nested',
    },
    children: [
      {
        // id:"93b26c5b2d374cdd8f15378b778898e8",
        path: 'flowingWater',
        component: () => import('@/views/finance/flowingWater'),
        name: 'flowingWater',
        meta:{ title: '流水记录', icon: 'guide'}
      },
       {
        // id:"cd7711aa1e244795a37ee671bc53969e",
        path: 'rechargeRecord',
        component: () => import('@/views/finance/rechargeRecord'),
        name: 'rechargeRecord',
        meta:{ title: '充值记录', icon: 'guide'}
      }
    ]
  },
  {
    id:"d3f4da6ce81f435c8dbf2319e41c7579",
    path: '/system',
    component: Layout,
    name: 'System',
    meta: {
      title: '系统管理',
      icon: 'nested'
    },
    children: [
      {
        id:"f2be8c10b62d407f9d3132edd3bb54ad",
        path: 'user',
        component: () => import('@/views/system/user/index'),
        name: 'User',
        meta: { title: '用户管理', icon: 'guide' }
      },
      {
        id:"264c2f1e83a84765bbb8245920f589ee",
        path:'department',
        component: () => import('@/views/system/department/index'),
        name:'Department',
        meta: { title: '部门管理', icon: 'guide'}
      },
      {
        id:"9e786aff6bea4daaaadf2cac3b6a95b4",
        path: 'role',
        component: () => import('@/views/system/role/index'),
        name: 'Role',
        meta: { title: '角色管理', icon: 'guide' }
      },
    ]
  },

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
